package com.zjh.mybase.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class CalTime {
    @Pointcut("execution(void com.zjh.mybase.dao.UserDao.index())")
    private void pt(){}

    @Before("pt()")
    private void printTime(){
        System.out.println(System.currentTimeMillis());
    }

    @Around("pt()")
    private Object load(ProceedingJoinPoint pj) throws Throwable {
        System.out.println("开始时间"+System.currentTimeMillis());
       Object object = pj.proceed();
        System.out.println("结束时间"+System.currentTimeMillis());
        return object;
    }
}
